package com.lazycat.backend.service.impl.address;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lazycat.backend.mapper.AddressMapper;
import com.lazycat.backend.mapper.UserAddressMapper;
import com.lazycat.backend.pojo.Address;
import com.lazycat.backend.pojo.UserAddress;
import com.lazycat.backend.service.address.UpdateAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class UpdateAddressServiceImpl implements UpdateAddressService {

    @Autowired
    private AddressMapper addressMapper;


    @Override
    public Map<String, Object> update(Integer addressId, String tag, String address, String contact, String phoneNumber) {


        QueryWrapper<Address> addressQueryWrapper = new QueryWrapper<>();

        addressQueryWrapper.eq("address_id", addressId);
        Address addr = addressMapper.selectOne(addressQueryWrapper);
        addr.setAddress(address);
        addr.setContact(contact);
        addr.setPhoneNumber(phoneNumber);
        addr.setTag(tag);
        addressMapper.update(addr, addressQueryWrapper);
        HashMap<String, Object> resp = new HashMap<>();
        resp.put("error_message", "success");
        return resp;
    }
}
